package com.ehl.utb.cloud.test.log;

import org.apache.ibatis.logging.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 自定义mybatis-plus 日志实现用来在日志文件中打印sql语句
 *
 * 使用方式： 在配置文件中配置mybatis-plus 的日志实现类
 * mybatis-plus:
 *   configuration:
 *     ###mybatis-plus配置控制台打印完整带参数SQL语句
 *     log-impl: com.ehl.utb.event.log.EhlMyBatisPlusLogImpl
 *
 * <p>
 * 文件名称：{@link EhlMyBatisPlusLogImpl}
 * <p>
 * <b>
 * Creation Time: 2022/9/3
 *
 * @author lyw
 * @version 1.0.0.0
 * @since 1.0.0.0
 **/
public class EhlMyBatisPlusLogImpl implements Log {

    private final Logger log;

    public EhlMyBatisPlusLogImpl(String clazz) {
        log = LoggerFactory.getLogger(clazz);
    }

    @Override
    public boolean isDebugEnabled() {
        return true;
    }

    @Override
    public boolean isTraceEnabled() {
        return true;
    }

    @Override
    public void error(String s, Throwable e) {
        this.log.error(s, e);
    }

    @Override
    public void error(String s) {
        this.log.error(s);
    }

    @Override
    public void debug(String s) {
        this.log.info(s);
    }

    @Override
    public void trace(String s) {
        this.log.trace(s);
    }

    @Override
    public void warn(String s) {
        this.log.warn(s);
    }
}
